/**
 *  DBEXEL is a Database Backed & Web-Based Worksheet and chart management program. 
 *  It has been influenced by Excel.
 *  For questions or suggestions please contact the developper at ( Development@Gandomi.com )
 *  Copyright (C) 2011 Baubak Gandomi   
 *
 *	This file is part of the application DBEXEL
 *
 *   DBEXEL is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   DBEXEL is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package dbexel.presentation.actions;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

import dbexel.model.dao.WorkSheetDao;
import dbexel.model.dao.WorkSheetDaoImpl;
import dbexel.model.mapping.WorkSheet;

public class WorkSheetAction {

	private List<WorkSheet> workSheetList = new ArrayList<WorkSheet>();
	private WorkSheetDao workSheetDao;

	public String tstExecute() {
		WorkSheet l_ws1 = new WorkSheet("Worskeet Nr. 1");
		l_ws1.setWs_Id(Long.valueOf(11));
		WorkSheet l_ws2 = new WorkSheet("Worskeet Nr. 3");
		l_ws2.setWs_Id(Long.valueOf(13));
		WorkSheet l_ws3 = new WorkSheet("Worskeet Nr. 5");
		l_ws3.setWs_Id(Long.valueOf(17));
		WorkSheet l_ws4 = new WorkSheet("Worskeet Nr. 7");
		l_ws4.setWs_Id(Long.valueOf(19));

		getWorkSheetList().add(l_ws1);
		getWorkSheetList().add(l_ws2);
		getWorkSheetList().add(l_ws3);
		getWorkSheetList().add(l_ws4);

		return ActionSupport.SUCCESS;

	}

	public String fetchWorkSheets() {
		workSheetDao = new WorkSheetDaoImpl();
		//setWorkSheetList(getWorkSheetDao().findAllWorkSheets());
		workSheetList = getWorkSheetDao().fetchAllWorkSheets();
		return ActionSupport.SUCCESS;
	}

	/**
	 * @param workSheetList
	 *            the workSheetList to set
	 */
	public void setWorkSheetList(List<WorkSheet> workSheetList) {
		this.workSheetList = workSheetList;
	}

	/**
	 * @return the workSheetList
	 */
	public List<WorkSheet> getWorkSheetList() {
		return workSheetList;
	}

	public void setWorkSheetDao(WorkSheetDao workSheetDao) {
		this.workSheetDao = workSheetDao;
	}

	public WorkSheetDao getWorkSheetDao() {
		return workSheetDao;
	}
}
